﻿using Joy.Erp.BasicArchives;
using Joy.Erp.Ufida.Core;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp;

namespace Joy.Erp.Ufida.ProductionUnit
{
    [RemoteService(Name = BasicArchivesRemoteServiceConsts.RemoteServiceName)]
    [Area(BasicArchivesRemoteServiceConsts.ModuleName)]
    [ControllerName("WorkCenterSync")]
    [Route("api/basic-archives/work-center-sync")]
    public class WorkCenterSyncController : UfidaController, IWorkCenterSyncAppService
    {
        protected IWorkCenterSyncAppService WorkCenterSyncAppService => LazyServiceProvider.LazyGetRequiredService<IWorkCenterSyncAppService>();

        [HttpPost]
        [Route("analyze")]
        public Task<AnalysisDto> Analyze‌Async()
        {
            return WorkCenterSyncAppService.Analyze‌Async();
        }

        [HttpGet]
        [Route("unasync-ids")]
        public Task<List<long>> GetUnasyncIds()
        {
            return WorkCenterSyncAppService.GetUnasyncIds();
        }

        [HttpGet]
        [Route("synced-ids")]
        public Task<List<long>> GetSyncedIds()
        {
            return WorkCenterSyncAppService.GetSyncedIds();
        }

        [HttpPost]
        [Route("create-by-ids")]
        [ServiceFilter(typeof(CreateByIdExceptionFilter))]
        public Task<int> CreateByIds‌Async(long[] ids)
        {
            return WorkCenterSyncAppService.CreateByIds‌Async(ids);
        }

        [HttpPost]
        [Route("update-by-ids")]
        [ServiceFilter(typeof(CreateByIdExceptionFilter))]
        public Task<int> UpdateByIds‌Async(long[] ids)
        {
            return WorkCenterSyncAppService.UpdateByIds‌Async(ids);
        }
    }
}
